export function getDate(type,date){
  var now = new Date();
  if(date!=undefined&&date!=''){
    now = new Date(date.replace(/-/g,'/'))
  }
  var year = now.getFullYear();
  var month = now.getMonth() + 1;
  var day = now.getDate();
  if(month < 10) {
    month = '0' + month;
  };
  if(day < 10) {
    day = '0' + day;
  };
  var nowtime = new Date();
  //  如果需要时分秒，就放开
  var h = nowtime.getHours();
  var m = nowtime.getMinutes();
  // var s = nowtime.getSeconds();
  if(m.toString().length<2){
    m = '0' + m
  }
  var formatDate = type==1?(year + '年' + month + '月' + day + '日'):type==2?(year + '-' + month + '-' + day ): year + '-' + month + '-' + day + ' ' + h + ':' + m;
  // var formatDate = year + '年' + month + '月' + day + '日' + h + ':' + m + ':' + s;
  return formatDate
}
//获取昨天
export function yesterday(){
  //昨天的时间
  var day1 = new Date();
  day1.setTime(day1.getTime()-24*60*60*1000);
  var s1 = day1.getFullYear()+"-" + (day1.getMonth()+1) + "-" + day1.getDate();
  //拼接时间
  var formatDate = s1;
  return formatDate
}
// 日期参数格式：yyyy-mm-dd
// a: 日期a, b: 日期b, flag: 返回的结果
export function comptime(a,b) {
  let flag = ''
  let value1 = new Date(a)
  let value2 = new Date(b)
  if(value1 <= value2){
    flag = "true";
    return flag;
  }else{
    flag = "false";
    return flag;
  }
}